package com.moji.service.impl;

import com.moji.entity.MjWorkOrder;
import com.moji.entity.MjWorkOrderDetail;
import com.moji.entity.dto.ReplyWorkDto;
import com.moji.mapper.MjWorkOrderDetailMapper;
import com.moji.service.MjWorkOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moji.util.IdGenerator;
import com.moji.util.MoJiCommonUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * <p>
 * 电子工单明细表 服务实现类
 * </p>
 *
 * @author ccl
 * @since 2024-08-20
 */
@Service
public class MjWorkOrderDetailServiceImpl extends ServiceImpl<MjWorkOrderDetailMapper, MjWorkOrderDetail> implements MjWorkOrderDetailService {

    @Resource
    private IdGenerator idGenerator;

    @Override
    public boolean add(ReplyWorkDto replyWorkDto) {
        MjWorkOrderDetail mjWorkOrderDetail=new MjWorkOrderDetail();
        BeanUtils.copyProperties(replyWorkDto,mjWorkOrderDetail);
        String workCode= idGenerator.idGenerator("DZGDMX");
        mjWorkOrderDetail.setWorkMxCode(workCode);
        mjWorkOrderDetail.setUserCode(MoJiCommonUtils.getUserCode());
        mjWorkOrderDetail.setUserName(MoJiCommonUtils.getUserName());
        mjWorkOrderDetail.setCreateId(MoJiCommonUtils.getUserCode());
        mjWorkOrderDetail.setUpdateId(MoJiCommonUtils.getUserCode());
        mjWorkOrderDetail.setCreateTime(new Date());
        mjWorkOrderDetail.setUpdateTime(new Date());
        mjWorkOrderDetail.setSpareInt1(0);
        return this.save(mjWorkOrderDetail);
    }
}
